package com.lagou.web.interceptor;

import com.lagou.web.util.ThreadLocalUtil;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @AUTHOR: yb.feng
 * @DATE: 2020/6/15 22:30
 * @DESC:
 */
@Component
public class IpInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        ThreadLocalUtil.setIp(request.getRemoteAddr());
        return true;
    }
}
